import Vue from 'vue'

interface Ievent {
  emit(subject: string, ...args: any[]),

  on(subject: string | string[], cb: Function),

  once(subject: string, cb: Function),

  off(subject: string | string[], cb?: Function)
}

class Event implements Ievent {
  private vue: any = new Vue();

  emit(subject: string, ...args: any[]) {
    this.vue.$emit(subject, ...args);
  }

  on(subject: string | string[], cb: Function) {
    this.vue.$on(subject, cb);
  }

  once(subject: string, cb: Function) {
    this.vue.$once(subject, cb);
  }

  off(subject: string | string[], cb?: Function) {
    this.vue.$off(subject, cb);
  }
}

export default new Event();
